import request from './index'
import { ElMessage } from 'element-plus'

// 获取秒杀商品列表
export function getSeckillList() {
  return request({
    url: '/seckillProduct/list',
    method: 'get'
  })
}

// 获取秒杀商品详情
export function getSeckillDetail(id) {
  return request({
    url: `/seckillProduct/${id}`,
    method: 'get'
  })
}

// 执行秒杀
export function doSeckill(productId) {
  return request({
    url: `/seckillOrder/add/${productId}`,
    method: 'post'
  })
}

// 搜索秒杀商品
export function searchSeckillProducts(keyword) {
  return request({
    url: '/seckillProduct/search',
    method: 'get',
    params: { keyword }
  })
}

// 获取秒杀订单列表
export function getSeckillOrderList() {
  return request({
    url: '/seckillOrder/list',
    method: 'get'
  })
}

// 支付秒杀订单
export function paySeckillOrder(id) {
  return request({
    url: `/seckillOrder/pay/${id}`,
    method: 'post'
  })
}

// 取消秒杀订单
export function cancelSeckillOrder(id) {
  return request({
    url: `/seckillOrder/cancel/${id}`,
    method: 'post'
  })
}

// 完成秒杀订单
export function completeSeckillOrder(id) {
  return request({
    url: `/seckillOrder/complete/${id}`,
    method: 'post'
  })
}

// 申请退款
export function refundSeckillOrder(id) {
  return request({
    url: `/seckillOrder/refund/${id}`,
    method: 'post'
  })
} 